package opengl.renderer;

public class RendererFactory {
	public static GLRenderer getGLRenderer(GLRendererTypeEnum type) {
		switch (type) {
		case IMMEDIATE:
			return getGLRendererImmediate();
		case VERTEX_ARRAY:
			return getGLRendererVAO();
		case FontUnicode:
			return getGLRendererFontUnicode();
		default:
			return getGLRendererImmediate();
		}		
	}

	public static LSRenderer setLSRenderer(LSRendererTypeEnum type) {
		switch (type) {
		case BASE:
			return getLSRendererBase();
		case QUAD:
			return getLSRendererQuad();
		}

		return getLSRendererBase();
	}

	public static GLRenderer getGLRendererImmediate() {
		return getInstance().glRendererImmediate;
	}

	public static GLRenderer getGLRendererVAO() {
		return getInstance().glRendererVAO;
	}
	
	public static GLRendererFontUnicode getGLRendererFontUnicode() {
		return getInstance().glRendererFontUnicode;
	}

	public static LSRenderer getLSRendererBase() {
		return getInstance().lineStripRendererBase;
	}

	public static LSRenderer getLSRendererQuad() {
		return getInstance().lineStripRendererQuad;
	}

	//------------------------------------------------------------------private
	private GLRenderer glRendererImmediate;
	private GLRenderer glRendererVAO;
	private GLRendererFontUnicode glRendererFontUnicode;

	private LSRenderer lineStripRendererBase;
	private LSRenderer lineStripRendererQuad;

	private static RendererFactory instance;
	
	private RendererFactory() {
	}
	private static RendererFactory getInstance() {
		if (instance == null) {
			instance = new RendererFactory();
			instance.init();
		}
		return instance;
	}

	private void init() {
		this.glRendererImmediate = new GLRendererImmediate();
		this.glRendererVAO = new GLRendererVAO();
		this.lineStripRendererBase = new LSRendererBase();
		this.lineStripRendererQuad = new LSRendererQuad();
		this.glRendererFontUnicode = new GLRendererFontUnicode();
	}

	
}
